package com.hotel.order.mq;

import com.hotel.common.utils.DBTools;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import static com.hotel.order.config.RabbitConfig.PAYMENT_SUCCESS_QUEUE;

@Component
public class PaymentSuccessListener {

    @RabbitListener(queues = PAYMENT_SUCCESS_QUEUE)
    public void onPaymentSuccess(Long orderId) {
        DBTools.update("UPDATE orders SET status='PAID' WHERE id=?", orderId);
    }
}
